package cn.baddonkey.photography.agent.utils;

import cn.baddonkey.photography.agent.entity.BaseEntity;

import java.util.Date;

public class EntityUtils {

    public static void setInsertEntityInfo(BaseEntity baseEntity) {
        String userId = SecurityUtils.getUserId();
        Date now = new Date();
        baseEntity.setCreatedTs(now);
        baseEntity.setUpdatedTs(now);
        baseEntity.setCreatedBy(userId);
        baseEntity.setUpdatedBy(userId);
        baseEntity.setDeleted(false);
    }

    public static void setUpdateEntityInfo(BaseEntity baseEntity) {
        String userId = SecurityUtils.getUserId();
        Date now = new Date();
        baseEntity.setUpdatedTs(now);
        baseEntity.setUpdatedBy(userId);
    }
}
